#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QFileDialog>
#include <QTextStream>
#include <QMessageBox>
#include <QProcess>
#include <QTimer>
#include <QTime>
#include <QFile>
#include "aboutdialog.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void on_pushButton_scan_clicked();

    void on_pushButton_open_clicked();

    void on_Serial_ReadyRead();

    void on_pushButton_close_clicked();

    void on_pushButton_pause_clicked();

    void on_pushButton_clrSend_clicked();

    void on_pushButton_clrRecv_clicked();

    void on_checkBox_clearcnt_toggled(bool checked);

    void on_pushButton_Send_clicked();

    void on_checkBox_disptime_toggled(bool checked);

    void on_checkBox_dispsend_toggled(bool checked);

    void on_actionSave_triggered();

    void on_actionLoad_triggered();

    void on_radioButton_rec_hex_toggled(bool checked);

    void on_radioButton_rec_ascii_toggled(bool checked);

    void on_actionAbout_XSerial_triggered();

    void on_radioButton_send_ascii_toggled(bool checked);

    void on_radioButton_send_hex_toggled(bool checked);

    void on_checkBox_repeat_toggled(bool checked);

    void on_spinBox_repeat_valueChanged(int arg1);

private:
    Ui::MainWindow *ui;
    QSerialPort *serial;
    QProcess *authpcs;
    QTimer *rptimer;
    bool auth;
    bool paused;
    bool clearcnt;
    bool timetrap;
    bool dispsend;
    bool disphex;
    bool sendhex;
    unsigned long sendcnt;
    unsigned long recvcnt;

private:
    void connected_nable();
    void disconnected_nable();
    void initial_nable();
    void refreshrecv(QString str, bool send);
};
#endif // MAINWINDOW_H
